from sqlmodel import SQLModel, Field, Index
from datetime import datetime

class WpCollection(SQLModel, table=True):
    """Waveup藏品表数据库模型"""
    __tablename__ = "t_wp_collection"  # 对应数据库表名

    # 索引定义（优化查询性能）
    __table_args__ = (
        Index("idx_productId", "productId", unique=True, info="藏品编码唯一索引"),
    )

    # 字段定义
    id: int = Field(default=None, primary_key=True, index=True, description="主键ID")
    productId: str = Field(default="", max_length=64, description="藏品编码")
    productName: str = Field(default="", max_length=128, description="藏品名称")
    imageUrl: str = Field(default="", max_length=256, description="藏品图片URL")
    detailUrl: str = Field(default="", max_length=256, description="藏品详情URL")
    description: str = Field(default="", max_length=2046, description="藏品描述")
    issueAuthor: str = Field(default="", max_length=128, description="藏品发行方")
    issueAmount: int = Field(default=0, description="藏品发行数量")
    archiveId: int = Field(default=0, description="藏品所属档案ID")
    platformId: int = Field(default=0, description="藏品所属平台ID")
    createdAt: datetime = Field(default_factory=datetime.now, description="创建时间")
    updatedAt: datetime = Field(default_factory=datetime.now, description="更新时间")